#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 64;
typedef vector<vector<int>> mat;
typedef vector<int> vec;
mat zero(int n) {
    mat val(n, vector<int>(n));
    return val;
}
mat operator*(const mat &v1, const mat &v2) {
    int n = v1.size();
    mat res = zero(n);
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < n; k++) {
            int r1 = v1[i][k];
            for (int j = 0; j < n; j++) {
                res[i][j] = (res[i][j] + 1ll * r1 * v2[k][j] % MOD) % MOD;
            }
        }
    }
    return res;
}
vec operator*(const vec &v1, const mat &v2) {
    int n = v1.size();
    vec res(n);
    for (int j = 0; j < n; j++) {
        long long sum = 0;
        for (int i = 0; i < n; i++) {
            sum = sum + 1ll * v1[i] * v2[j][i] % MOD;
        }
        res[j] = sum%MOD;
    }
    return res;
}
vec operator*(const mat &v1, const vec &v2) {
    int n = v1.size();
    vec res(n);
    for (int j = 0; j < n; j++) {
        long long sum = 0;
        for (int i = 0; i < n; i++) 
        {
            sum = sum + 1ll * v2[i] * v1[i][j] % MOD;
        }
        res[j] = sum%MOD;
    }
    return res;
}
int operator*(const vec &v1, const vec &v2) {
    int n = v1.size();
    int res = 0;
    for (int i = 0; i < n; i++) {
        res = (res + 1ll * v1[i] * v2[i] % MOD) % MOD;
    }
    return res;
}
mat qpow(mat x, int p) {
    int n = x.size();
    mat res = zero(n);
    for (int i = 0; i < n; i++) {
        res[i][i] = 1;
    }
    while (p) {
        if (p & 1) {
            res = res * x;
        }
        x = x * x;
        p >>= 1;
    }
    return res;
}
int qpow(int x, int p) {
    int res = 1;
    while (p) {
        if (p & 1) {
            res = 1ll * res * x % MOD;
        }
        x = 1ll * x * x % MOD;
        p >>= 1;
    }
    return res;
}
vector<int> trs[20];
vector<int> gv[20], giv[20];
const int G = 3, GINV = (MOD + 1) / 3;
void init() {
    for (int p = 0; p <= 19; p++) {
        int lgt = p;
        int tot = 1 << p;
        trs[p] = vector<int>(tot);
        gv[p] = vector<int>(tot);
        giv[p] = vector<int>(tot);
        for (int j = 1; j < tot; j++) {
            trs[p][j] = (trs[p][j >> 1] >> 1) | ((j & 1) << (lgt - 1));
        }
        gv[p][0] = giv[p][0] = 1;
        int v = qpow(G, (MOD - 1) / tot);
        for (int j = 1; j < tot; j++) {
            gv[p][j] = 1ll * gv[p][j - 1] * v % MOD;
        }
        int vinv = qpow(GINV, (MOD - 1) / tot);
        for (int j = 1; j < tot; j++) {
            giv[p][j] = 1ll * giv[p][j - 1] * vinv % MOD;
        }
    }
}
vector<int> FFT(const vector<int> &rin, int tot, int lgt) {
    vector<int> res(tot);
    for (int i = 0; i < tot; i++) {
        if (trs[lgt][i] < rin.size()) {
            res[i] = rin[trs[lgt][i]];
        }
    }
    for (int i = 1; i <= lgt; i++) {
        int len = 1 << i;
        int hlen = len >> 1;
        for (int j = 0; j < tot; j += len) {
            for (int k = j; k < j + hlen; k++) {
                int v1 = res[k], v2 = 1ll * res[k + hlen] * gv[i][k - j] % MOD;
                res[k] = (v1 + v2) % MOD;
                res[k + hlen] = (v1 - v2 + MOD) % MOD;
            }
        }
    }
    return res;
}
vector<int> IFFT(const vector<int> &rin, int tot, int lgt) {
    vector<int> res(tot);
    for (int i = 0; i < tot; i++) {
        if (trs[lgt][i] < rin.size()) {
            res[i] = rin[trs[lgt][i]];
        }
    }
    for (int i = 1; i <= lgt; i++) {
        int len = 1 << i;
        int hlen = len >> 1;
        for (int j = 0; j < tot; j += len) {
            for (int k = j; k < j + hlen; k++) {
                int v1 = res[k], v2 = 1ll * res[k + hlen] * giv[i][k - j] % MOD;
                res[k] = (v1 + v2) % MOD;
                res[k + hlen] = (v1 - v2 + MOD) % MOD;
            }
        }
    }
    return res;
}
inline vector<int> operator%(const vector<int> &rin, int md) {
    vector<int> res = rin;
    res.resize(md);
    return res;
}
vector<int> inv(const vector<int> &rin, int mod) {
    vector<int> res(1, qpow(rin[0], MOD - 2));
    while (res.size() < mod ) {
        int gs = res.size() * 2;
        int elen = gs * 2;
        int lgt = 32 - __builtin_clz(elen), tot = 1 << lgt;
        vector<int> v1 = FFT(res, tot, lgt), v2 = FFT(rin % gs, tot, lgt);
        for (int i = 0; i < tot; i++) {
            v1[i] = (2ll * v1[i] + MOD - 1ll * v1[i] * v1[i] % MOD * v2[i] % MOD) % MOD;
        }
        res = IFFT(v1, tot, lgt) % gs;
        int inv = qpow(tot, MOD - 2);
        for (int &v : res) {
            v = 1ll * v * inv % MOD;
        }
    }
    return res % mod;
}
vector<int> operator-(const vector<int> &v1, const vector<int> &v2) {
    vector<int> res = v1;
    if (v2.size() > v1.size()) {
        res.resize(v2.size());
    }
    for (int j = 0; j < v2.size(); j++) {
        res[j] = (res[j] - v2[j] + MOD) % MOD;
    }
    return res;
}
vector<int> ans[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    init();
    int n, m;
    cin >> n >> m;
    vector<vector<int>> mt(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> mt[j][i];
        }
    }
    int b = sqrt(m);
    //cerr << b << '\n';
    int cnt = m / b + (m % b != 0);
    mat sqt = qpow(mt, b);
    for (int i = 0; i < n; i++) {
        vec pre(n);
        vector<vec> p1, p2;
        for (int j = 0; j < n; j++) {
            if ((i & j) == i) {
                pre[j] = 1;
            }
        }
        p1.push_back(pre);
        p2.push_back(pre);
        for (int i = 1; i <= b; i++) {
            p1.push_back(mt * p1.back());
        }
        for (int i = 1; i <= cnt; i++) {
            p2.push_back(p2.back() * sqt);
        }
        vector<int> G(m + 1);
        G[0] = 0;
        for (int j = 1; j <= m; j++) {
            G[j] = p1[j % b] * p2[j / b];
        }
        ans[i] = inv(vector<int>(1, 1) - G, m + 1);
        //cerr<<i<<'\n';
    }
    for (int j = 0; (1 << j) < n; j++) {
        for (int S = 0; S < n; S++) {
            if ((S >> j) & 1) {
                ans[S ^ (1 << j)] = ans[S ^ (1 << j)] - ans[S];
            }
        }
    }
    int rans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= m; j++) {
            rans ^= ans[i][j];
        }
    }
    cout << rans << '\n';
}